package com.huiketong.cofpasgers.repository;

import com.huiketong.cofpasgers.entity.LinShare;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Repository
public interface LinShareRepository extends JpaRepository<LinShare,Integer>{
        LinShare findLinShareByTypeAndCompanyId(Integer type,Integer companyId);

        List<LinShare> findLinSharesByCompanyId(Integer companyId);

        LinShare findLinShareById(Integer id);

        @Override
        <S extends LinShare> S save(S s);

        @Transactional
        @Modifying
        @Query(value = "update lin_share set title = ?1,content = ?2,img_url = ?3,topimg = ?4,bottomimg = ?5,backgroud=?6,type = ?7,url = ?8 where id = ?9",nativeQuery = true)
        void updateLinShare(String title,String content,String img_url,String upimg,String downimg,String bgcolor,Integer type,String url,Integer id);
}
